﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace DAL
{
    public static class HashingPassword
    {
        public static string CreatePasswordSalt(int size)
        {
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            byte[] buff = new byte[size];
            rng.GetBytes(buff);
            return Convert.ToBase64String(buff);
        }
        public static string CreatePasswordHash(string OriginalPassword, string PasswordSalt)
        {
            string saltAndPwd = String.Concat(OriginalPassword, PasswordSalt);
            SHA1Managed sha1 = new SHA1Managed();
            byte[] text = Encoding.UTF8.GetBytes(saltAndPwd);
            byte[] result = sha1.ComputeHash(text);
            return Convert.ToBase64String(result);
        }
    }
}
